module(
    name = "emsdk",
    version = "4.0.21",
)

bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "aspect_rules_js", version = "1.42.0")
bazel_dep(name = "rules_nodejs", version = "6.3.2")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_python", version = "1.3.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    python_version = "3.13",
)

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
node.toolchain(node_version = "20.18.0")
use_repo(node, "nodejs")

emscripten_deps = use_extension(
    "//:emscripten_deps.bzl",
    "emscripten_deps",
)
use_repo(emscripten_deps, "emscripten_bin_linux")
use_repo(emscripten_deps, "emscripten_bin_linux_arm64")
use_repo(emscripten_deps, "emscripten_bin_mac")
use_repo(emscripten_deps, "emscripten_bin_mac_arm64")
use_repo(emscripten_deps, "emscripten_bin_win")

npm = use_extension(
    "@aspect_rules_js//npm:extensions.bzl",
    "npm",
)
npm.npm_translate_lock(
    name = "emscripten_npm_linux",
    data = ["@emscripten_bin_linux//:emscripten/package.json"],
    npm_package_lock = "@emscripten_bin_linux//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
    name = "emscripten_npm_linux_arm64",
    data = ["@emscripten_bin_linux_arm64//:emscripten/package.json"],
    npm_package_lock = "@emscripten_bin_linux_arm64//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
    name = "emscripten_npm_mac",
    data = ["@emscripten_bin_mac//:emscripten/package.json"],
    npm_package_lock = "@emscripten_bin_mac//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
    name = "emscripten_npm_mac_arm64",
    data = ["@emscripten_bin_mac_arm64//:emscripten/package.json"],
    npm_package_lock = "@emscripten_bin_mac_arm64//:emscripten/package-lock.json",
)
npm.npm_translate_lock(
    name = "emscripten_npm_win",
    data = ["@emscripten_bin_win//:emscripten/package.json"],
    npm_package_lock = "@emscripten_bin_win//:emscripten/package-lock.json",
)
use_repo(
    npm,
    "emscripten_npm_linux",
    "emscripten_npm_linux_arm64",
    "emscripten_npm_mac",
    "emscripten_npm_mac_arm64",
    "emscripten_npm_win",
)

emscripten_cache = use_extension("//:emscripten_cache.bzl", "emscripten_cache")
use_repo(emscripten_cache, "emscripten_cache")

register_toolchains(
    "//emscripten_toolchain:cc-toolchain-wasm-emscripten_linux",
    "//emscripten_toolchain:cc-toolchain-wasm-emscripten_linux_arm64",
    "//emscripten_toolchain:cc-toolchain-wasm-emscripten_mac",
    "//emscripten_toolchain:cc-toolchain-wasm-emscripten_mac_arm64",
    "//emscripten_toolchain:cc-toolchain-wasm-emscripten_win",
)
